<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/admin/inc/tag.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML><HEAD><TITLE>购物车</TITLE>
<META content="text/html; charset=UTF-8" http-equiv=Content-Type>
<META name=keywords content="">
<META name=description content=>
<LINK rel=stylesheet type=text/css href="/pc/product/css/list.css" media=all><META name=GENERATOR content="MSHTML 8.00.7601.17940">
<script type="text/javascript" src="js/jquery-1.7.min.js"></script>
<script type="text/javascript" src="/pc/js/setcook.js"></script>
<script type="text/javascript">
	function deleteProduct(productId){
		var trolleyJSON=get_cookie("trolleyJSON");

		var trolleyArray;
		if(trolleyJSON==undefined||trolleyJSON=="undefined"){
			trolleyArray=new Array();
		}else{
			trolleyArray=JSON.parse(trolleyJSON);
		}

		for(var i=trolleyArray.length-1;i>=0;i--){
			if(trolleyArray[i].product_id==productId){
				for(var j=trolleyArray.length-2;j>=0;j--){
					trolleyArray[j]=trolleyArray[j+1];
				}
				trolleyArray.length--;
				break;
			}
		}

		trolleyJSON=JSON.stringify(trolleyArray);
		setCookie("trolleyJSON",trolleyJSON);

		refreshTrolley();
	}
	function clearTrolley(){
		if (confirm("确定要清空购物车吗？")) {
			deleteCookie("trolleyJSON");
		}

		refreshTrolley();
	}
	function refreshTrolley(){
		var href=window.location.pathname;
		window.location=href;
	}
//	clearTrolley();
	function checkForm() {
		if($("#scheme_customer_name").val() == "") {
			alert("请输入姓名！");
			return false;
		}
		if($("#scheme_customer_mobile").val() == "") {
			alert("请输入手机！");
			return false;
		}
		if($("#scheme_customer_qq").val() == "") {
			alert("请输入QQ！");
			return false;
		}
		
		for(var i=0; i<checkArray.length; i++) {
			var id = checkArray[i];
			var value = $("#" + id).val();
			if(value == null || value == "") {
				alert("*号为必选配置，请您选择完整！");
				return false;
			}
		}
		return true;
	}
</script>
</HEAD>
<BODY><DIV class="wraper clearfix">
<DIV class=main><!-- 产品搜索 -->
<DIV class="chooseBox mb10">
<DIV id=J-getWap class=getWap style="font-size:20px;text-align:center;">购物车</DIV>
</DIV><!-- screen1 end -->
<pc:trolley name="trolley"/>
<form id="buy_form" action="/pc/product/saveTrolley.do" method="post" onsubmit="return checkForm();">
<DIV class=main-ivy790><U id=pc.jrbj.$$bj.bjym.b20796.s20811.2J.zz1. 
class=adpos></U></DIV><!-- 产品列表 -->
<DIV class="product-box mb10">
<DIV class=content><!-- 默认列表 -->
<input type="hidden" name="productIds" value="${trolley_productIds}"/>
<input type="hidden" name="totalPrice" value="${trolley_totalPrice}"/>
<table width="100%" border="0" cellpadding="5" cellspacing="0">
	<tr style="height:30px;line-height:30px;font-size:22px;border-bottom:#cacaca 1px dashed;">
		<th width="50%" style="text-align:center;">产品</th>
		<th width="20%" style="text-align:center;">单价</th>
		<th width="20%" style="text-align:center;">数量</th>
		<th width="10%" style="text-align:center;">操作</th>
	</tr>
	<c:forEach items="${trolley}" var="product">
		<tr style="border-bottom:#cacaca 1px dashed;">
			<td align="left">
				<input type="hidden" name="product_id_${product_id}" value="${product.product_id}"/>
				<IMG id=img_502730 src="${product.product_pic_url}" width=120 height=90/>
				${product.product_name}
			</td>
			<td align="center"><EM style="font:700 21px/22px 宋体;color:#C00;">￥${product.product_price}</EM></td>
			<td align="center"><input type="text" name="num_${product.product_id}" value="${product.num}" size="3" style="height:25px;line-height:25px;font-size:22px;text-align:right;padding:0;"/></td>
			<td align="center"><a href="#" onclick="javascript:deleteProduct(${product.product_id});return false;">删除</a></td>
		</tr>
	</c:forEach>
</table>
<DIV class=turn-page-detail>
<DIV class=pconline_page>
	<a href="#" onclick="javascript:refreshTrolley();return false;">刷新购物车</a>
	<a href="#" onclick="javascript:clearTrolley();return false;">清空购物车</a>
	共<EM style="font:700 21px/22px 宋体;color:#C00;"><fmt:formatNumber value="${trolley_totalPrice}" pattern="0.00"/></EM>元
</DIV>
</DIV>
<DIV style="height:50px;line-height:50px;float:right;margin:10px 0;">
	<UL id=formPostArea class=post_the_card>
		<LI>
			<DIV class=usr_login style="font-size:14px;">
				姓名：<INPUT id="scheme_customer_name" type=text name="scheme_customer_name" value="${scheme.scheme_customer_name}" style="height:20px;line-height:20px;"/>&nbsp;&nbsp;&nbsp;
				手机：<INPUT id="scheme_customer_mobile" type=text name="scheme_customer_mobile" value="${scheme.scheme_customer_mobile}" style="height:20px;line-height:20px;"/>&nbsp;&nbsp;&nbsp;
				QQ：<INPUT id="scheme_customer_qq" type=text name="scheme_customer_qq" value="${scheme.scheme_customer_qq}" style="height:20px;line-height:20px;"/>
				<input type="submit" id="buy_btn" value="购买" style="padding:0 15px;"/>
			</DIV>
		</LI>
	</UL>
</DIV>
</DIV></DIV><!-- screen2 end --></DIV><!-- main.end--></DIV>
</form>
</BODY></HTML>
